#ifndef OVERLAY_H
#define OVERLAY_H

#include <string>
#include "BaseUnit.h"
#include "StatefulSprite.h"
#include "Vector2df.h"
#include "CollisionRegion.h"
class LevelMap;

class Overlay : public BaseUnit
{
    public:
        Overlay();
        Overlay(const Vector2di p, const Vector2di s, uint transparentColour);
        Overlay(string identifier, string imagefile, const Vector2di p, const Vector2di s, uint transparentColour);
        Overlay(string identifier, string imagefile, string target, const Vector2di p, const Vector2di s, uint transparentColour);
        Overlay(StatefulSprite *sprite);
        virtual ~Overlay();

        virtual int getWidth() const;
        virtual int getHeight() const;
        virtual Vector2df getSize() const;
        LevelMap *getLevelMap() const {return m_levelMap;}
        virtual int getState() const;

        void setSpriteState(string stateName);
        string getSpriteState() const { if (m_statefulSprite) return m_statefulSprite->getSpriteState(); else return "None";};
        void setLevelMap(LevelMap *levelMap) {m_levelMap = levelMap;}

        virtual void update();
        virtual void checkCollision();
        virtual void hit(const SimpleDirection dir, BaseUnit* const player, CRstring parameter="");
        virtual void hitMap(MapData* const data, const CollisionObject* const obj);
        void render();
        bool hasFinished() const { if (m_sprite) return m_sprite->hasFinished(); else return false; };
        bool hasReachedEnd() const { if (m_sprite) return m_sprite->hasFinished(); else return false; };
        void playSound(string soundName) { if (m_statefulSprite) m_statefulSprite->playSound(soundName);};
        virtual void handleEvent(string eventName);
        //bool hasCollisionFlag(CRint flag){if (m_statefulSprite) return m_statefulSprite->m_collisionFlags.hasFlag(flag); else return false;}
        //CollisionRegion* getCollision() const {return m_collisionRegion; }//{if (m_statefulSprite) return m_statefulSprite->getCollisionForState(getSpriteState()); else return m_collisionRegion;};

        void addSpriteState(string state, uint sheetWidth, uint sheetHeight, uint startIndex, uint numFrames, uint frameRate, uint transparentColour);
        string getIdentifier() {return m_identifier;}
        string getTarget() {return m_target;}
    protected:
        bool m_isGeneric;
        SDL_Surface *m_surface;
        StatefulSprite *m_statefulSprite;
        //CollisionRegion *m_collisionRegion;
        string m_currentSpriteState;
        string m_identifier;
        string m_target;
        uint m_transparentColour;
        LevelMap *m_levelMap;
    private:
};

#endif // OVERLAY_H
